<template>
  <div class="app-container">
    <el-form
      inline
      size="small"
      ref="queryForm"
      :model="queryParams"
      v-show="showSearch"
      label-width="68px"
    >

      <el-form-item label="人员搜索" prop="nickName">
        <el-input
          style="width: 215px"
          v-model="queryParams.nickName"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-table :data="list" border>
      <el-table-column
        label="所属部门"
        prop="deptName"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        label="人员角色"
        prop="roleName"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        label="人员姓名"
        prop="nickName"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        label="手机号"
        prop="phone"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        label="当前订单数"
        prop="orderNumber"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column label="操作" width="280" align="center" fixed="left">
        <template slot-scope="{ row }">
          <template >
            <el-button
              type="text"
              size="mini"
              @click="commit(row)"
            >选择</el-button>
          </template>

        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import Template from "@/views/system/template";
import {checkPermi} from "@/utils/permission";
import {getDriverList} from "@/api/charteredBus/add";

export default {
  components: {Template},
  props: ['storeId', 'driverType'],
  data() {
    return {
      list: [],
      // 总条数
      total: 0,
      // 显示搜索条件
      showSearch: true,
      queryParams: {
        storeId: this.storeId,
        driverType: this.driverType,
        nickName:null,
        pageNum: 0, //页码   必选
        pageSize: 10, //每页显示数据 必选
      },
    }
  },
  mounted() {
    console.log('mounted')
    this.queryParams.storeId = this.storeId
    this.queryParams.driverType = this.driverType
    this.getList()
  },
  updated() {
    console.log('updated')
  },
  methods: {

    getList() {
      getDriverList(this.queryParams).then((response) => {
        this.list = response.rows
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },

    commit(data){
      this.$emit('success', data)
    }
  },
}
</script>
